<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" href="/mdui/css/mdui.min.css">
    <script defer src="/mdui/js/mdui.min.js"></script>
    <script src="/js/axios.min.js"></script>
    <script src="/js/qs.min.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/vue.js"></script>


</head>
<body class="mdui-theme-primary-indigo mdui-theme-accent-pink">


<div class="mdui-container-fluid" id="app">
    <h1 class="mdui-text-color-theme">上传</h1>

    <form>
        <div class="mdui-textfield">

            <label class="mdui-textfield-label">描述</label>
            <input class=" mdui-textfield-input" type="text" v-model="descr" name="descr"/>
        </div>

        <div class="mdui-textfield">

            <label class="mdui-textfield-label">描述</label>
            <input class=" mdui-textfield-input" type="file" id="file" name="file"/>
        </div>
    </form>

    <div>
        <button @click="dosubmit" class="mdui-btn mdui-color-theme-accent mdui-ripple">提交</button>
    </div>

</div>

<script>

    let vm = new Vue({
        el: "#app",
        data: {
            descr: '',
        },

        methods: {
            dosubmit() {
                // let fd = new FormData()
                // fd.append("descr", this.descr)
                // fd.append("file", document.getElementById("file").files(0))

                //2
                let fd = new FormData(document.forms[0])//form里的输入框要有name属性

                axios.post("/uplode/uplodefile", fd)
                    .then(function (res) {
                        if (res.data.success) {
                            mdui.alert("上传成功")
                        }

                    })
            }
        }
    })
</script>


</body>
</html>